package searchteam.client.ui.callbacks;

import java.util.Collection;

import searchteam.client.beansMirrors.PersonMirror;
import searchteam.client.ui.widgets.Display;
import searchteam.client.ui.widgets.InfoPopUp;
import searchteam.client.ui.widgets.PersonMirrorDisplay;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class getAllPersonsCallback implements AsyncCallback<Collection<PersonMirror>>{

	private Display panel;
	
	public getAllPersonsCallback(Display p) {
		panel = p;
	}
	
	public void onFailure(Throwable caught) {
		panel.clearMirrors();
		new InfoPopUp(caught.getMessage(), "Erreur");
	}

	public void onSuccess(Collection<PersonMirror> result) {
		panel.clearMirrors();
		
		for(PersonMirror p : result) {
			panel.addMirror(new PersonMirrorDisplay(panel, p));
		}
		
	}

}
